#ifndef PLAYER_HPP_INCLUDED
#define PLAYER_HPP_INCLUDED

#include <string>
#include <vector>

#include "formula_callable.hpp"
#include "player_fwd.hpp"
#include "tile_logic.hpp"
#include "unit.hpp"
#include "wml_node_fwd.hpp"

namespace game {

class scenario;

class player : public game_logic::formula_callable {
public:
	struct game_aborted {};

	static player_ptr read(wml::const_node_ptr node);

	explicit player(wml::const_node_ptr node);
	virtual ~player();
	const std::string& id() const { return id_; }
	bool is_hostile(const player& p) const;
	virtual void play_turn(scenario& s) = 0;

	virtual void start_scenario();

	void remove_dead_commanders();

	const std::vector<commander_unit_ptr>& commanders() const { return commanders_; }

	int color_index() const { return color_index_; }

	const std::vector<hex::location>& starting_locs() const { return starting_locs_; }
	void add_commander(commander_unit_ptr cmd);
protected:
	variant get_value(const std::string& key) const;
	void set_value(const std::string& key, const variant& value);

private:

	std::string id_;
	std::string team_;
	std::vector<commander_unit_ptr> commanders_;
	int color_index_;

	std::vector<hex::location> starting_locs_;
};
}

#endif
